<template>
  <div class="car">
    <h2>一辆{{car.brand}}车，价值{{car.price}}万</h2>
    <button @click="changePrice">修改价格</button>
    <hr>
    <h2>当前求和为：{{sum}}个</h2>
    <button @click="changeSum">点击+1</button>
    <button @click="changeObj">点击改车</button>
  </div>
</template>

<script setup lang="ts" name="Car">
import {reactive,ref} from 'vue'
  // 数据
  let car = reactive({brand:'奔驰',price:100})
  let sum = ref(0)
  // 方法
  function changePrice(){
    car.price += 10
  }

  function changeSum(){
    sum.value +=1
  }
  function changeObj(){
    Object.assign(car,{brand:'吉利',price:20})
  }
</script>

<style scoped>
.car {
  background-color: skyblue;
  box-shadow: 0 0 10px 0;
  padding: 10px;
  border-radius: 10px;
}
</style>